﻿using System;
using System.Linq;
using NUnit.Framework;

namespace Abs.Core.UnitTesting
{
    //[TestFixture]
    public class RoomManagement
    {
        public Management.RoomManagement ManageRoom { get; set; }
        public string RoomName { get; set; }
        public int RoomId { get; set; }
        public int TotalRooms { get; set; }
        public int DayId { get; set; }
        public DateTime StartTime { get; set; }
        public DateTime EndTime { get; set; }
        public int TotalRoomSchedules { get; set; }

        //[TestFixtureSetUp]
        public void BeforeTests()
        {
            this.ManageRoom = Management.Manage.Room;
            this.RoomName = "Element";
            this.RoomId = 5;
            this.TotalRooms = 5;
            this.DayId = (int) DayOfWeek.Monday;
            this.StartTime = DateTime.Parse("09:00:00");
            this.EndTime = DateTime.Parse("15:00:00");
            this.TotalRoomSchedules = 6;
        }//end of public void BeforeTests()

        //[Test]
        public void IsManageRoomNull()
        {
            Assert.IsNotNull(this.ManageRoom);
        }//end of public void IsManageRoomNull()

        //[Test]
        public void AddRoom()
        {
            var isSuccess = this.ManageRoom.CreateRoom(this.RoomName);
            Assert.True(isSuccess);
        }//end of public void CreateRoom()

        //[Test]
        public void AddRoomSchedule()
        {
            var isSuccess = this.ManageRoom.CreateRoomSchedule(this.RoomId,
                                                               this.DayId, 
                                                               this.StartTime.ToString("HH:mm:ss"),
                                                               this.EndTime.ToString("HH:mm:ss"));
            Assert.True(isSuccess);
        }//end of public void AddRoomSchedule()

        //[Test]
        public void CheckRoomId()
        {
            var roomId = this.ManageRoom.RoomIdentity;
            Console.WriteLine(roomId);
            Assert.AreEqual(this.RoomId, roomId);
        }//end of public void CheckRoomId()

        //[Test]
        public void EditRoom()
        {
            this.RoomName = "Element Room";
            var isSuccess = this.ManageRoom.UpdateRoom(this.RoomId, this.RoomName);
            Assert.True(isSuccess);
        }//end of public void EditRoom()

        //[Test]
        public void EditRoomSchedule()
        {
            this.EndTime = this.EndTime.AddHours(3);
            var isSuccess = this.ManageRoom.EditRoomSchedule(this.RoomId,
                                                               this.DayId, 
                                                               this.StartTime.ToString("HH:mm:ss"),
                                                               this.EndTime.ToString("HH:mm:ss"));
            Assert.True(isSuccess);
        }//end of public void EditRoomSchedule()

        //[Test]
        public void ReadRoom()
        {
            var room = this.ManageRoom.SelectRoom(this.RoomId);
            Assert.AreEqual(this.RoomName, room.Name);
        }//end of public void ReadRoom()

        //[Test]
        public void ReadRoomSchedule()
        {
            var roomSchedule = this.ManageRoom.SelectRoomSchedule(this.RoomId, this.DayId);
            Assert.AreEqual(this.EndTime, roomSchedule.EndTime);
        }//end of public void ReadRoomSchedule()

        //[Test]
        public void ReadAllRooms()
        {
            var totalRooms = this.ManageRoom.SelectAllRoom().Count();
            Assert.AreEqual(this.TotalRooms, totalRooms);
        }//end of public void ReadAllRooms()

        //[Test]
        public void ReadAllRoomSchedules()
        {
            var totalRoomSchedules = this.ManageRoom.SelectAllRoomSchedules().Count();
            Assert.AreEqual(this.TotalRoomSchedules, totalRoomSchedules);
        }//end of public void ReadAllRoomSchedules()

        //[Test]
        public void RemoveSelectedRoom()
        {
            var isSuccess = this.ManageRoom.DeleteRoom(this.RoomId);
            Assert.True(isSuccess);
        }//end of public void RemoveSelectedRoom()

        //[Test]
        public void RemoveRoomSchedule()
        {
            var isSuccess = this.ManageRoom.DeleteRoomSchedule(this.RoomId, this.DayId);
            Assert.IsTrue(isSuccess);
        }//end of public void RemoveRoomSchedule()

        //[Test]
        public void RemoveRoomScheduleByRoomId()
        {
            var isSuccess = this.ManageRoom.DeleteRoomScheduleByRoomId(1);
            Assert.IsTrue(isSuccess);
        }//end of public void RemoveRoomScheduleByRoomId()
    }//end of public class RoomManagement
}//end of namespace ABS.UnitTesting